package vn.csp.managed.bean;

import java.io.Serializable;

import javax.faces.bean.ManagedProperty;

import org.springframework.stereotype.Controller;

import vn.csp.managed.util.FacesUtil;
@Controller
public class NavigationController implements Serializable {
	private static final long serialVersionUID = 1L;

//	@ManagedProperty(value = "#{param.pageId}")
	private String pageId;

	public String moveToPage1() {
		return "page1";// phân giải page1 -> page1.jsf
	}

	public String moveToPage2() {
		return "page2";
	}

	public String moveToHomePage() {
		return "home";
	}

	public String processPage1() {
		return "page";
	}

	public String processPage2() {
		return "page";
	}
	public String showPage() 
	{	
		pageId = FacesUtil.getRequestParameter("pageId");
		if (pageId == null) {
			return "home";
		}
		if (pageId.equals("1")) {
			return "page1";
		} else if (pageId.equals("2")) {
			return "page2";
		} else {
			return "home";
		}
	}

	public String getPageId() {
		return pageId;
	}

	public void setPageId(String pageId) {
		this.pageId = pageId;
	}
}
